﻿using AdvancedDataGridView;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace txtTEST
{
    public partial class Form4 : Form
    {

     
        public Form4()
        {
            InitializeComponent();
        }

        private void Form4_Load(object sender, EventArgs e)
        {
            //attachmentColumn.DefaultCellStyle.NullValue = null;

            // load image strip
            this.imageList1.ImageSize = new System.Drawing.Size(16, 16);
            this.imageList1.TransparentColor = System.Drawing.Color.Magenta;
            this.imageList1.ImageSize = new Size(16, 16);
            this.imageList1.Images.AddStrip(Properties.Resources.newGroupPostIconStrip);

            treeGridView1.ImageList = imageList1;


            List<personcl> lst = new List<personcl>();
            personcl per1 = new personcl { name = "cese", age = 2, na = 1 };
            lst.Add(per1);
            personcl per2 = new personcl { name = "cese", age = 3, na = 1 };
            per1.subitem.Add(per2);
            personcl per3 = new personcl { name = "cese", age = 4, na = 1 };
            per1.subitem.Add(per3);

            

            SetNodes(lst, treeGridView1.Nodes);


            personcl2 lst2 = new personcl2 { name = "cese", age = 5, na = 1 };
            SetNodes2(lst2, treeGridView1.Nodes);

            personcl2 lst3 = new personcl2 { name = "cese", age = 6, na = 1 };
            SetNodes2(lst3, treeGridView1.Nodes);

            personcl2 lst4 = new personcl2 { name = "cese", age = 7, na = 1 };
            SetNodes2(lst4, treeGridView1.Nodes);
        }

        private void button1_Click(object sender, EventArgs e)
        {


        }



        public class personcl
        {
            public string name = "";
            public int age = 0;
            public int na = 0;

            public List<personcl> subitem = new List<personcl>();
        }

        public class personcl2
        {
            public string name = "";
            public int age = 0;
            public int na = 0;
        }


        private void SetNodes(IEnumerable<personcl> lst, TreeGridNodeCollection nodes)
        {

            foreach (var item in lst)
            {
                var node = nodes.Add(item.name, item.age,item.na);
                node.ImageIndex = 0;
                SetNodes(item.subitem, node.Nodes);
            }
        }

        private void SetNodes2(personcl2 lst, TreeGridNodeCollection nodes)
        {

            var node = nodes.Add(lst.name, lst.age, lst.na);
            node.ImageIndex = 1;
        }

    }



}
